/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.support.systemmessage.ui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import com.qihoo.gamecenter.sdk.common.i.s;

public class a {
    private WindowManager a = null;
    private MessageFloatWindow b = null;
    private boolean c = false;
    private Handler d = new Handler();
    private a e;
    private Runnable f = new Runnable() {
        public void run() {
            a.this.a();
        }
    };

    public void a(a parama) {
        this.e = parama;
    }

    public void a(Context paramContext, com.qihoo.gamecenter.sdk.support.systemmessage.a parama) {
        if (this.c)
            a();
        a(paramContext);
        if (null == this.b) {
            this.b = new MessageFloatWindow(paramContext);
            this.b.setListener(new MessageFloatWindow.a() {
                public void a(Context paramContext, com.qihoo.gamecenter.sdk.support.systemmessage.a parama) {
                    a.this.a();
                    a.this.a(paramContext, parama.a);
                }
            });
        }
        this.d.removeCallbacks(this.f);
        this.b.setMsg(parama);
        WindowManager.LayoutParams localLayoutParams = b(paramContext);
        localLayoutParams.height = s.b(paramContext, 50.0F);
        localLayoutParams.gravity = 51;
        this.a.addView(this.b, localLayoutParams);
        this.c = true;
        this.d.postDelayed(this.f, 6000L);
    }

    public void a() {
        if (!(this.c))
            return;
        try {
            this.a.removeView(this.b);
        } catch (Exception localException) {
            com.qihoo.gamecenter.sdk.support.g.a.c("MessageWindowManager", new Object[] { localException.toString() });
        }
        this.c = false;
        if (this.e == null)
            return;
        this.e.a(this.b.a());
    }

    public void a(Context paramContext, String paramString) {
        Intent localIntent = new Intent();
        localIntent.putExtra("function_code", 2059);
        localIntent.putExtra("sysmsg_list_expand_msg", paramString);
        localIntent.setClassName(paramContext, "com.qihoo.gamecenter.sdk.activity.ContainerActivity");
        if (!(paramContext instanceof Activity))
            localIntent.addFlags(268435456);
        paramContext.startActivity(localIntent);
    }

    private void a(Context paramContext) {
        if (null != this.a)
            return;
        this.a = ((WindowManager) paramContext.getApplicationContext().getSystemService("window"));
    }

    private WindowManager.LayoutParams b(Context paramContext) {
        WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
        localLayoutParams.type = 2002;
        localLayoutParams.format = 1;
        localLayoutParams.flags = 40;
        return localLayoutParams;
    }

    public static abstract interface a {
        public abstract void a(com.qihoo.gamecenter.sdk.support.systemmessage.a parama);
    }
}